package com.xuecheng.content.controller;

import com.xuecheng.api.content.model.CourseAuditApi;
import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseBaseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.convert.CourseBaseConvert;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class CourseAuditController implements CourseAuditApi {
    @Autowired
    private CourseBaseService courseBaseService;

    @PostMapping("/m/course/list")
    public PageVO queryCourseBaseList(PageRequestParams params,  @RequestBody QueryCourseBaseModel model) {
        /** todo  调用courseBaseService 中的分页条件查询的条件
         * params  分页条件当前页和每页条数
         * model   分页条件查询的条件
         * null    机构id,因为运行平台是对各教学机构课程进行审核,并不需要数据隔离,因此该变量为空
         * pageVO 返回对象中封装着当前页数,每页条数,以及当前页的所有数据
         */
        PageVO pageVO = courseBaseService.queryCourseBaseList(params, model, null);

        return pageVO;
    }
/*
todo  课程审核
 */
    @Override
    @PostMapping("m/courseReview/approve")
    public void approveCourse(@RequestBody  CourseAuditVO courseAuditVO) {
        //todo  vo转dto
        CourseBaseDTO courseBaseDTO = CourseBaseConvert.INSTANCE.courseAuditVO2dto(courseAuditVO);
        courseBaseService.approveCourse(courseBaseDTO);
    }

}
